import java.io.*;
import java.util.*;
/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(                    //为输入做初始化，以空格分辨每一个输入
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {   //读取一个或一组字符串
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {     //将next()读取的字符串转化成整型
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {   //读next()读取的字符串转化成双精度型
        return Double.parseDouble( next() );
    }
}

class Student {
    String id;
    int d;
    int c;
    int sum;
    boolean f1;

    public Student() {
    }

    public Student(String id, int d, int c, int sum) {
        this.id = id;
        this.d = d;
        this.c = c;
        this.sum = sum;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getD() {
        return d;
    }

    public void setD(int d) {
        this.d = d;
    }

    public int getC() {
        return c;
    }

    public void setC(int c) {
        this.c = c;
    }

    public int getSum() {
        return sum;
    }

    public void setSum(int sum) {
        this.sum = sum;
    }

    @Override
    public String toString() {
        return id +" " + d +" " + c;
    }

}
class SumComparator implements Comparator<Student>{

    @Override
    public int compare(Student o1, Student o2) {
        if(o2.sum - o1.sum == 0){
            if(o1.d == o2.d){
                return o1.id.compareTo(o2.id);
            }else {
                return o2.d-o1.d;
            }
        }else {
            return o2.sum - o1.sum;
        }

    }
}



public class Test {
    public static void main(String[] agrs) throws IOException {
         Reader.init(System.in);
        int n =   Reader.nextInt();
        int l =   Reader.nextInt();
        int h = Reader.nextInt();
       Student[] list1 = new Student[(int)Math.pow(10,5)];
       Student[] list2= new Student[(int)Math.pow(10,5)];
       Student[] list3 = new Student[(int)Math.pow(10,5)];
       Student[] list4 = new Student[(int)Math.pow(10,5)];
        for (int i = 0; i < n; i++) {
            Student student = new Student();
            student.id = Reader.next();
            student.d =Reader.nextInt();
            student.c = Reader.nextInt();
            if (student.d >= l && student.c >= l) {
                student.sum = student.d + student.c;
                if (student.d >= h) {
                    if (student.c >= h) {
                        list1[i]=student;
                    } else {
                        list2[i]=student;
                    }
                } else {
                    if (student.d >= student.c) {
                        list3
                    } else {
                        list4.add(student);
                    }
                }
            } else {
                continue;
            }
        }
        SumComparator sumComparator = new SumComparator();
        Collections.sort(list1,sumComparator);
        Collections.sort(list2,sumComparator);
        Collections.sort(list3,sumComparator);
        Collections.sort(list4,sumComparator);
        System.out.println(list1.size()+list2.size()+list3.size()+list4.size());
        for (int i = 0; i < list1.size(); i++) {
            System.out.println(list1.get(i));
        }
        for (int i = 0; i < list2.size(); i++) {
            System.out.println(list2.get(i));
        }
        for (int i = 0; i < list3.size(); i++) {
            System.out.println(list3.get(i));
        }
        for (int i = 0; i < list4.size(); i++) {
            System.out.println(list4.get(i));
        }
    }


}